<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model="msg">
        <span>{{msg|upper}}</span>
        <span>{{msg|upper|lower}}</span>
        <span v-bind:abc="msg|upper">测试数据</span>

    </div>
    <script src="../js/vue.min.js"></script>
    <script>
        // 全局定义
        Vue.filter('upper', function(val) {
            return val.charAt(0).toUpperCase() + val.slice(1);
        })
        Vue.filter('lower', function(val) {
            return val.charAt(0).toLowerCase() + val.slice(1);
        })

        let vm = new Vue({
            el: '#app',
            data: {
                msg: '',
            },
            // 局部定义,只能在本组件使用,也就是实例vm
            filter: {
                upper: function(val) {
                    return val.charAt(0).toUpperCase() + val.slice(1);
                }
            }
        })
    </script>
</body>

</html>